#include "hzpch.h"
#include "WindowsInput.h"
#include "Hazel/src/Hazel/Application.h"
#include <GLFW/glfw3.h>
namespace Hazel{

    Input* Input::s_Instance=new WindowsInput();

    bool WindowsInput::IsKeyPressedImpl(int keycode)
    {
        auto window=Application::Get().GetWindow().GetNativeWindow();
        auto state=glfwGetKey((GLFWwindow*)window,keycode);
        return state==GLFW_PRESS||state == GLFW_REPEAT;
    }
    bool WindowsInput::IsMouseButtonPressedImpl(int button)
    {
        auto window=Application::Get().GetWindow().GetNativeWindow();
        auto state=glfwGetMouseButton((GLFWwindow*)window,button);
        return state==GLFW_PRESS;
    }
    float WindowsInput::GetMouseXImpl()
    {
        auto window=Application::Get().GetWindow().GetNativeWindow();
        double XPos,YPos;
        glfwGetCursorPos((GLFWwindow*)window,&XPos,&YPos);

        return (float)XPos;
    }
    float WindowsInput::GetMouseYImpl()
    {
        auto window=Application::Get().GetWindow().GetNativeWindow();
        double XPos,YPos;
        glfwGetCursorPos((GLFWwindow*)window,&XPos,&YPos);
        return (float)YPos;
    }
    std::pair<float, float> WindowsInput::GetMousePositionImpl()
    {
        auto window=Application::Get().GetWindow().GetNativeWindow();
        double XPos,YPos;
        glfwGetCursorPos((GLFWwindow*)window,&XPos,&YPos);
        return {(float)XPos,(float)YPos};
    }
}